﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.Security;
using System.Web.UI.WebControls;

public partial class Administration_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.User.IsInRole(MyWebPagesStarterKit.RoleNames.Administrators.ToString()) && Page.User.Identity.IsAuthenticated)
        {
            Response.Redirect("Default.aspx");
        }
    }

    protected void LoginUser(object sender, EventArgs e)
    {
        if (Membership.ValidateUser(txtUserName.Text, txtPassword.Text))
        {
            FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true);
            //Response.Redirect("/administration/Default.aspx");
        }
        else
        {
            litErr.Text = "<p color=\"red\">Wrong username or password.</p>";
        }
    }
}
